export default{
    routes:[
      {
          path:'/home',
          component:()=>import('@/pages/Home/'),//懒加载组件
      },
      {
          path:'/login',
          component:()=>import('@/pages/Login/'),//懒加载组件
           meta:{noShow:true}
      },
      {
          path:'/register',
          component:()=>import('@/pages/Register/'),//懒加载组件
          meta:{noShow:true}
      },
      {
          path:'/search/:keyword?', //搜索组件
          name:'search',
          component:()=>import('@/pages/Search/')//懒加载组件
      },
      {
        path:'/detail/:id', //详情组件
        component:()=>import('@/pages/Detail/'),//懒加载组件
      },
      {
        path:'/addcartsuccess', //加入购物车成功组件
        component:()=>import('@/pages/AddCartSuccess/'),//懒加载组件
        beforeEnter:(to,from,next)=>{
            console.log(from.path.indexOf('/detail'))
            if(from.path.indexOf('/detail')>=0){
                next()
            }else{
                next(false)
            }
        }
      },
      {
        path:'/shopcart', //购物车
        component:()=>import('@/pages/ShopCart/')//懒加载组件
      },
      {
        path:'/trade', //订单
        component:()=>import('@/pages/Trade/'),//懒加载组件
        beforeEnter:(to,from,next)=>{
            if(from.path.indexOf('/shopcart')>=0){
                next()
            }else{
                next(false)
            }
        }
      },
      {
        path:'/pay', //支付
        component:()=>import('@/pages/Pay/'),//懒加载组件
         beforeEnter:(to,from,next)=>{ 
            if(from.path.indexOf('/trade')>=0){
                next()
            }else{
                next(false)
            }
        }
      },
      {
        path:'/paysuccess', //支付成功
        component:()=>import('@/pages/PaySuccess/')//懒加载组件
      },
      {
        path:'/ordercenter', //订单中心
        component:()=>import('@/pages/OrderCenter/'),//懒加载组件
        children:[
          {
            path:'myorder',
            component:()=>import('@/pages/OrderCenter/MyOrder/'),//懒加载组件
          },
          {
              path:'/',
              redirect:'myorder'
          }
        ] 
      },
      {
            path:'/',
            redirect:'/home'
      }
    ],
    scrollBehavior(){
      return  { x: 0, y: 0 }
    }
  }